home *** CD-ROM | disk | FTP | other *** search
/ BMUG PD-ROM B4 / PD-ROM B4.iso / Utilities / ResEdit / ResEdit Add-ins / GenericErrors Resources / GenericErrors.c < prev   
Encoding:
C/C++ Source or Header  |  1991-12-30  |  2.2 KB  |  76 lines  |  [TEXT/KAHL]

  1. /*_______________________________________________________________________
  2.  | _|_                                                                    |
  3.  |    ¿ GenericErrors                                         12/18/91        |
  4.  |                                                                         |
  5.  |     Simply call the routines like so:                                    |
  6.  |                                                                         |
  7.  |     FatalError("\pSorry, an error has occured.");                        |
  8.  |     StopError("\pSorry, an error has occured.");                        |
  9.  |     CautionError("\pSorry, an error has occured.");                        |
  10.  |     Message("\pSorry, an error has occured.");                            |
  11.  |                                                                         |
  12.  | Copyright © 1991 by Craig A. Marciniak          All rights reserved.    |
  13.  _______________________________________________________________________*/
  14.  
  15.  #define    ERRORTEMPLATE      200
  16.  
  17.  /*_________________________ Generic FatalError ________________________*/
  18.  
  19. void FatalError(char *message)
  20. {    
  21.     ParamText(message,NULL,NULL,NULL);
  22.     CenterDialog ('ALRT',ERRORTEMPLATE);
  23.     StopAlert(ERRORTEMPLATE,NIL);
  24.     ExitToShell();
  25. }
  26.  
  27. /*_________________________ Generic StopError __________________________*/
  28.  
  29. void StopError(char *message)
  30. {    
  31.     ParamText(message,NULL,NULL,NULL);
  32.     CenterDialog ('ALRT',ERRORTEMPLATE);
  33.     StopAlert(ERRORTEMPLATE,NIL);
  34. }
  35.  
  36. /*_______________________ Generic Caution Error ________________________*/
  37.  
  38. void CautionError(char *message)
  39. {
  40.     ParamText(message,NULL,NULL,NULL);
  41.     CenterDialog ('ALRT',ERRORTEMPLATE);
  42.     CautionAlert(ERRORTEMPLATE,NIL);
  43. }
  44.  
  45. /*_________________________ Generic Message ____________________________*/
  46.  
  47. void Message(char *message)
  48. {
  49.     ParamText(message,NULL,NULL,NULL);
  50.     CenterDialog ('ALRT',ERRORTEMPLATE);
  51.     NoteAlert(ERRORTEMPLATE,NIL);
  52. }
  53.  
  54. /*_________________ Center dialog or alert template ____________________*/
  55.                 /* pass 'ALRT' or 'DLOG' for templateType */
  56.     
  57. void CenterDialog (long templateType,short templateID)    
  58. {
  59.     register Rect **h;
  60.     register Rect *p;
  61.     register short width, height;
  62.     
  63.     if (!(h = (Rect **)GetResource(templateType, templateID)))
  64.         return;
  65.     p = *h;
  66.     width = p->right - p->left;
  67.     height = p->bottom - p->top;
  68.     p->top = 20 + screenBits.bounds.top + 
  69.         ((screenBits.bounds.bottom - screenBits.bounds.top) - height)/3;
  70.     p->bottom = p->top + height;
  71.     p->left = screenBits.bounds.left + 
  72.         ((screenBits.bounds.right - screenBits.bounds.left) - width)/2;
  73.     p->right = p->left + width;
  74. }
  75.  
  76. /*______________________________________________________________________*/